home *** CD-ROM | disk | FTP | other *** search
- On Fri, 17 Feb 1995, Max Monahan wrote:
-
- [...]
- >
- > Now I want the cars to have some interaction with the background. I would
- > like to have a track, or perhaps just some obstacles to avoid which would
- > cause damage also. What is the best way of going about achieving collision
- > detection with the background and with various objects around the track.
- > e.g. a grandstand or fence or an oil slick.
- > The cars are currently bobs but there is probably no reason why they
- > cannot be sprites.
- > Should I just draw the background in a certain colour range and check
- > for collision with certain colours
-
- I don't think this is the "best" way...
-
- > ( I think this method was used in the
- > space ship shoot em up game which came with AMOS,-its name escapes me)
- > or create the background using bobs and use bob collision techniques.
- > Any suggestions?
-
- WHat I would suggest is a Background collision lookup table... this also
- works especially well if you plan to render the course from a set of
- tile primitives..
-
- Basically you just look up the 'collision' status for whatever 'tile' the
- car is on... So you have to compute which tile your on by examing the
- game map... Example:
-
- Tiles: Description Collison Status
- 1 -> a piece of track 0 (ie. no collision status)
- 2 -> grass 0
- 3 -> tree 1 (ie. collision)
-
- Tiles are 16x16 pixels for example.
-
- Race Track Map:
-
- 2222222222 --> This would give you a (160,96) race track
- | 2222332222 (ie. grass on the side of the track with 3 trees)
- + 1111111111
- y 1111111111 Of course in your game you will need more tiles and
- | 2222222232 a bigger map but the idea is exactly the same.
- V 2222222222
- ---+x-->
-
- You can compute at what (xm,ym) in the map (ie. map co-ordinates) your
- car is at from its pixel co-ordinates (xp,yp) using:
-
- xm = xp / (tile width) = xp / 16
- ym = yp / (tile height)= yp / 16
-
- Tile Under Car = Map(xm,ym)
-
- Now that you know what tile your on you just use it to look up the
- collision status...
-
- if Collsion(Map(xm,ym))=1
- ** collison **
- else
- ** no collisn **
-
- For speed you should make the 'divisions' in the pixel->map co-ordinate
- formulas either shifts or just pre-calculated. Depdending on how
- you decide to implement the Game Map (ie. array/memory bank/etc..)
- you can do the same things.
-
- One other thing that could make it fast is caching current tile lookups
- but I have never bothered to do this...
-
- In your case you would probably want to set up most of the screen as
- the race track so you would need a (320/16)x(192/16) or 20x19 tile
- map.
-
- I hope this helps... if you need any clarifications just ask.. me
- english not good.
-
- >
- > Also there is a small amount of flicker which I would like to get rid of.
- > Any suggestions on removing that. i.e. Should I be using autoback 0 with
- > the bob update off and bob clear,bob draw techniques? I had a go at it
- > but couldn't get it working. Any suggestions on that one also would be
- > appreciated.
- >
-
- I use this technique... but I can't check any code right now.. but
- basically you turn off automatic bob update then you must expiclity
- say when to update your bob's...
-
- .
- .
- .
- Bob Update
- Screen Swap
- Wait Vbl
- .
-
- mike
- > -thanks in advance
- > Max
- >
-
-